package com.truing.flycodebill.settings.web.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 登录验证的拦截器，在达到目标资源之前拦截
 */
public class LoginInterceptor implements HandlerInterceptor {
    /**
     * 根据用户是否登陆成功决定是否拦截请求
     *   1、根据session中是否有该用户判断是否拦截
     *   2、如果session有该用户，则返回true登录成功
     *      如果session中没有该用户，则返回false让用户返回登录页面进行登录
     * @param httpServletRequest
     * @param httpServletResponse
     * @param o
     * @return
     * @throws Exception
     */
    @Override
    public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {

    }

    @Override
    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {

    }
}
